PROJECT(gion)

SET(
  GION_INC_DIR
  ./include/)

SET(
  GION_SRC_DIR
  ./src/)

SET(
  GION_SOURCES
  ${GION_SRC_DIR}/fd.cpp
  ${GION_SRC_DIR}/file_ptr.cpp
  ${GION_SRC_DIR}/socket.cpp)

IF(MSVC)
  SET(
    GION_SOURCES
    ${GION_SOURCES}
    ${GION_SRC_DIR}/win32_handle.cpp)
ELSE(MSVC)
  SET(
    GION_SOURCES
    ${GION_SOURCES}
    ${GION_SRC_DIR}/pthread.cpp)
  IF(CMAKE_BUILD_TYPE STREQUAL "release")
    SET(
      CMAKE_CXX_FLAGS
      "-Wall -O -DNDEBUG")
    SET(
      CMAKE_C_FLAGS
      "-Wall -O -DNDEBUG")
  ELSE(CMAKE_BUILD_TYPE STREQUAL "release")
    SET(
      CMAKE_CXX_FLAGS
      "-Wall -g")
    SET(
      CMAKE_C_FLAGS
      "-Wall -g")
  ENDIF(CMAKE_BUILD_TYPE STREQUAL "release")
ENDIF(MSVC)

INCLUDE_DIRECTORIES(${GION_INC_DIR})

IF(MSVC)
  set(
    GION_LIB_NAME_PREFIX
    lib)
ELSE(MSVC)
  set(
    GION_LIB_NAME_PREFIX)
ENDIF(MSVC)

SET(
  GION_LIB_NAME
  ${GION_LIB_NAME_PREFIX}gion)

ADD_LIBRARY(
  ${GION_LIB_NAME}
  STATIC
  ${GION_SOURCES})




LINK_LIBRARIES(${GION_LIB_NAME})

SET(GION_TEST_SRC_DIR ./test/)

ADD_EXECUTABLE(test_auto_array ${GION_TEST_SRC_DIR}/test_auto_array.cpp)
ADD_DEPENDENCIES(test_auto_array ${GION_LIB_NAME})
ADD_TEST(auto_array test_auto_array)

ADD_EXECUTABLE(test_auto_handle ${GION_TEST_SRC_DIR}/test_auto_handle.cpp)
ADD_DEPENDENCIES(test_auto_handle ${GION_LIB_NAME})
ADD_TEST(auto_handle test_auto_handle)

ENABLE_TESTING()
